export default {
	// 获取页面数据
	getTableData() {
		var params = {
			type:1,
			language: this.$store.getters.getLanguage,
			// page: this.$refs.Page.pagination.current,
			// limit: this.$refs.Page.pagination.pageSize
		}

		this.axiosGets("MainIndex/historyList", params, function(res) {

			this.tableData = res.data.data
			// res.data.data.data.forEach(item => {
			// 	if(item.type === 1) {
			// 		this.tableData.push(item)
			// 	}
			// })
			
			
			//分页
			// this.total = res.data.data.total
			console.log(this.total);
		})
	},

	//添加
	add() {
		// this.history('/admin/edit')
		this.$refs.Edit.isShow = true;
	},

	//编辑
	edit(scope) {
		this.$refs.Edit.form.id = scope.id;
		this.$refs.Edit.form.time = scope.time;
		this.$refs.Edit.form.sort = scope.sort;
		this.$refs.Edit.form.text = scope.text;

		this.$refs.Edit.isShow = true;
	},

	//删除
	remove(scope) {
		this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
			confirmButtonText: '确定',
			cancelButtonText: '取消',
			type: 'warning'
		}).then(() => {

			this.sureRemove(scope.banner_id);
		}).catch(() => {
			this.$message({
				type: 'info',
				message: '已取消删除'
			});
		});
	},

	//确定删除
	sureRemove(id) {

		this.axiosGets("index/homepage/banner_delete?banner_id=" + id, {}, function(res) {
			if (res.data.code === 0) {
				this.getTableData();
				this.msgSuccess(res.data.msg)
			} else {
				this.msgError(res.data.msg)
			}
		})
	},
	
	submit1(){
		
		let params = new FormData();
		
		if(this.upImg.file) {
			params.append('file', this.upImg.file);
		}
		params.language = this.$store.getters.getLanguage
		console.log(params);
		// if(this.form.id) {
			this.axiosPostFile('MainIndex/historyConfig', params , res => {
				if(res.data.code === 0) {
					this.msgSuccess(res.data.message);
					this.getTableData();
					this.isShow1 = false;
				}else {
					this.msgError(res.data.message)
				}
			})
		// }
	},
	submit2(){
		
		let params ={
			url : this.url
		};
		params.language = this.$store.getters.getLanguage
		console.log(params);
		// if(this.form.id) {
			this.axiosPostFile('MainIndex/historyUrl', params , res => {
				if(res.data.code === 0) {
					this.msgSuccess(res.data.message);
					this.getTableData();
					this.isShow2 = false;
				}else {
					this.msgError(res.data.message)
				}
			})
		// }
	},
	
	
	
	// //图片上传
	// handleAvatarSuccess(res) {
	// 	console.log(res);
	// 	// console.log(file);
	// 	//图片id
	// 	this.form.image_id = res.data.id;
	// 	//图片url
	// 	this.imageUrl = this.imgURL + res.data.image_url;
	// 	// this.form.url = res.data.image_url;
	// 	// this.dialogVisible = true;
	// },
}
